# _______________________________________________________________
## _preamble.R ----
# _______________________________________________________________

preamble <- function(verbose = FALSE){
  # load packages:
  pkgs <- c(
      "readxl", "tidyverse", "stargazer", "lfe", "modelr","lubridate", "randomizr",
      "estimatr", "ri2", "xtable", "janitor", "sjPlot", "ggeffects", 
      "prediction", "viridis", "sf", "plm", "lmtest",
      "sandwich", "patchwork", "estimatr", "interflex", "pastecs",
      "haven", "rnaturalearth", "rnaturalearthdata", "ggrepel",
      "electoral", "texreg"
    )
  
  suppressPackageStartupMessages(
    sapply(pkgs, require, character.only = TRUE)
  )
  
  # load functions:
  source("code/_functions.R")
  
  if(verbose){
    message(str_c("Loaded functions and following packages:\n", str_flatten(pkgs, ", ")))
  }
}


